// 在独立js脚本中定义比较长的回调函数
window.dash_clientside = Object.assign({}, window.dash_clientside, {
    clientside: {
        render_chart1: function (data) {
            // 根据id初始化绑定图表
            var myChart = echarts.init(document.getElementById('chart-container-demo1'));

            const option = {
                xAxis: {
                    data: data['x']
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        data: data['y'],
                        type: 'line',
                        smooth: true
                    }
                ]
            };

            // 渲染
            myChart.setOption(option);
        },
        render_chart2: function (data) {
            // 根据id初始化绑定图表
            var myChart = echarts.init(document.getElementById('chart-container-demo2'));

            const option = {
                xAxis: {
                    data: data['x']
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        data: data['y'],
                        type: 'line',
                        smooth: false,
                        itemStyle: {
                            normal: {
                                color: 'red',
                                lineStyle: {
                                    color: 'red'
                                }
                            }
                        }
                    }
                ]
            };

            // 渲染
            myChart.setOption(option);
        }
    }
});